<?php

namespace Admin\Controller;

class GuestController extends AdminController
{
	/**
	 * 订单列表
	 * @return [type] [description]
	 */
	public function showlist($range=0){
		//支付状态：已支付
		$where['status'] = 2;
		//今日订单数量
		$where['order'] = array('gt',strtotime(date('Y-m-d',time())));		
		$total['todayorders'] = D('Guest') -> where($where) -> count();	
		//今日充值总额
		$total['todaytotal'] = D('Guest') -> where($where) -> sum('price');
		$total['todaytotal'] = empty($total['todaytotal']) ? 0 : $total['todaytotal'];

		//本月订单数量
		$where['order'] = array('gt',strtotime(date('Y-m',time())));
		$total['monthorders'] = D('Guest') -> where($where) -> count();
		//本月充值总额
		$total['monthtotal'] = D('Guest') -> where($where) -> sum('price');
		$total['monthtotal'] = empty($total['monthtotal']) ? 0 : $total['monthtotal'];

		$data = D('Guest') -> showlist($range);
		foreach ($data[0] as &$v) {
			$v['become_time'] = $v['become_time']/(24*3600);						/* yxf 20171108 金额有几位小数就显示几位  S*/					$v['price'] =  floatval($v['price']);		
		}
		unset($v);				$total['monthtotal'] =  floatval($total['monthtotal']);		$total['todaytotal'] =  floatval($total['todaytotal']);				/* yxf 20171108 金额有几位小数就显示几位  E*/		
		$this -> assign('data', $data);
		$this -> assign('total', $total);
		$this -> display();
	}
}
